package com.baizhi.dao.jpa;

import com.baizhi.domain.jpa.ArticleData;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ArticleDataDao extends JpaRepository<ArticleData, Integer> {

    @Modifying  // JPQL进行更新或删除时，必须要使用该注解声明
    @Query("update ArticleData ad set ad.content = ?2 where ad.article.aid = ?1")
    void updateContentByAid(Integer aid, String content);

    @Modifying
    @Query("delete from ArticleData ad where ad.article.aid = ?1")
    void deleteByAid(Integer aid);

    @Modifying
    @Query(value = "drop table article_data", nativeQuery = true)
    void dropTable();
}
